home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 January / macformat-020.iso / Shareware City / Developers / ACL / Examples / ACL-World / Sources / Dialogs.cp < prev    next >
Encoding:
Text File  |  1994-10-01  |  3.0 KB  |  181 lines  |  [TEXT/MMCC]

  1.  
  2. /********************************************
  3.  **** ACL-World
  4.  ****
  5.  **** dialogs.cp
  6.  ****
  7.  **** Created:      24 August 1994
  8.  **** Modified:     25 August 1994
  9.  **** Version:      0
  10.  **** Compatible:   C++, Mac System 7
  11.  ****
  12.  **** Description:    Dialog methods
  13.  ****
  14.  *******************/
  15.  
  16. #include "ACL-World.h"
  17.  
  18.  
  19. //*************************************
  20.  
  21. void ACLWorld::introwarning(void)
  22. {
  23.     DialogPtr    dialog;
  24.     short        action;
  25.     
  26.     dialog = GetNewDialog(dlg_INTROWARNING,NULL,(WindowPtr)-1);
  27.     if (dialog)
  28.     {
  29.         ModalDialog(NULL,&action);
  30.         DisposDialog(dialog);    
  31.     }
  32. }
  33.  
  34. //*************************************
  35.  
  36. void ACLWorld::about(void)
  37. {
  38.     DialogPtr    dialog;
  39.     short        action;
  40.     
  41.     dialog = GetNewDialog(dlg_ABOUT,NULL,(WindowPtr)-1);
  42.     if (dialog)
  43.     {
  44.         ModalDialog(NULL,&action);
  45.         DisposDialog(dialog);    
  46.     }
  47. }
  48.  
  49.  
  50. //*************************************
  51.  
  52. void ACLWorld::pleasewait(Boolean openw)
  53. {
  54.     static DialogPtr    wdialog;
  55.     
  56.     if (openw)
  57.     {
  58.         wdialog = GetNewDialog(dlg_PLEASEWAIT,NULL,(WindowPtr)-1);
  59.         if (wdialog)
  60.         {
  61.             DrawDialog(wdialog);
  62.         }
  63.     }
  64.     else if (wdialog) DisposDialog(wdialog);
  65. }
  66.  
  67. //*************************************
  68.  
  69. void ACLWorld::openbasedialog(void)
  70. {    
  71.     dialog = GetNewDialog(dlg_DIALOG,NULL,(WindowPtr)-1);
  72.     
  73.     ShowWindow(dialog);
  74.     SetPort(dialog);
  75.     updatebasedialog();
  76.  
  77. }
  78.  
  79. void ACLWorld::closebasedialog(void)
  80. {
  81.     DisposDialog(dialog);
  82. }
  83.  
  84. short ACLWorld::processbasedialog(char &key, Point &p)
  85. {
  86.     EventRecord    theEvent;
  87.     WindowPtr    whichWindow;
  88.     DialogPtr    whichDlog;
  89.     short        itemHit;
  90.     short        part;
  91.  
  92.  
  93.     if (animbase) animbase->update();
  94.  
  95.     if (WaitNextEvent(everyEvent,&theEvent,0,NULL))
  96.     {
  97.         if(DialogSelect(&theEvent,&whichDlog,&itemHit)) 
  98.         {
  99.             switch(itemHit)
  100.             {
  101.                 case 2: return DO_MENU;
  102.                 case 3: return DO_CONTINUE;
  103.             }
  104.         }        
  105.             
  106.         switch(theEvent.what)
  107.         {
  108.             case updateEvt:
  109.             whichWindow = (WindowPtr)theEvent.message;
  110.             if (whichWindow==dialog)
  111.             {
  112.                 updatebasedialog();
  113.                 if (animbase) animbase->updatewindow();
  114.             }
  115.             break;
  116.  
  117.             case keyUp:
  118.             key = theEvent.message & charCodeMask;
  119.             return DO_KEYUP;                
  120.                 
  121.             case keyDown:
  122.             if (docmdkey(&theEvent)) return DO_QUIT;
  123.  
  124.             key = theEvent.message & charCodeMask;
  125.             return DO_KEY;                
  126.  
  127.             case mouseDown:
  128.             part = FindWindow(theEvent.where,&whichWindow);
  129.             if (whichWindow==dialog)
  130.             {
  131.                 switch(part)
  132.                 {
  133.                     case inGoAway:
  134.                     if (TrackGoAway(whichWindow,theEvent.where)) return DO_QUIT;
  135.                     break;
  136.                         
  137.                     case inDrag:
  138.                     DragWindow(whichWindow,theEvent.where,&qd.screenBits.bounds);
  139.                     break;
  140.                     
  141.                     case inContent:
  142.                     p = theEvent.where;
  143.                     GlobalToLocal(&p);
  144.                     if (animbase)
  145.                     {
  146.                         p.h -= animbase->getbasex();
  147.                         p.v -= animbase->getbasey();
  148.                     }
  149.                     return DO_MOUSECLICK;
  150.                 }
  151.             }
  152.             else
  153.             {
  154.                 switch(part)
  155.                 {
  156.                     case inMenuBar:
  157.                     if (domenubar(MenuSelect(theEvent.where))) return DO_QUIT;
  158.                     break;
  159.                 }
  160.             }
  161.                 
  162.             break;
  163.         }    
  164.     }
  165.  
  166.     return DO_NOTHING;
  167. }
  168.  
  169.  
  170. void ACLWorld::updatebasedialog(void)
  171. {
  172.     MoveTo(13,298);
  173.     LineTo(480,298);
  174.     
  175.     MoveTo(13,227);
  176.     LineTo(480,227);    
  177. }
  178.  
  179. //*************************************
  180.  
  181.